package github.flandre.examplemod.core.init.event;

import github.flandre.examplemod.client.gui.OpenGUI;
import github.flandre.examplemod.common.key.KeyBandinglist;
import github.flandre.examplemod.network.NetworkRegistryHandler;
import github.flandre.examplemod.network.Packet.KeyInputPKT;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;



@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class HelKeyEvents {
    @SubscribeEvent
    public static void onKeyPressed(InputEvent.KeyInputEvent event)
    {
        Minecraft instance = Minecraft.getInstance();
        if(instance.world == null)//没有创建世界时
            return;
        int key = event.getKey();
        //没有打开GUI 并且按下了
        if(instance.currentScreen == null && KeyBandinglist.keyBinding.isPressed())
        {
            //System.out.println("Z is Press");
            NetworkRegistryHandler.CHANNEL.sendToServer(new KeyInputPKT(key));
        }
    }
}
